perm filename LISP.IMP[F82,JMC] blob sn#679495 filedate 1982-10-01 generic text, type C, neo UTF8
COMMENT āŠ—   VALID 00003 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	lisp.imp[f82,jmc]	improvements to Lisp
C00004 00003	Features for a new Lisp
C00005 ENDMK
CāŠ—;
lisp.imp[f82,jmc]	improvements to Lisp

(setfr access-form value)  does the same as (setf access-form value)
and in addition saves the value of  access-form  on a stack.

(restore n)  restores everything that has been put on the stack
back to n.

Let's try to define it.

(defmacro setfr (a v) `(progn
			(setq ,stack (cons (cons a a) ,stack))
			(setf ,a ,v)))

(setq stack 'stack1)
(setq stack1 nil)

(setq x 3)

(setfr x 5)

(defmacro setfr (a v) (list 'progn
			    (list 'setq
				  stack
				  (list 'cons
					(list 'cons (list 'quote a) a)
					stack))
			    (list 'setq a v)))

(macroexpand '(setfr x 3))

(setq s nil)
(setfr x 7)
x
s
(defmacro setfr (a v)
	  `(progn (setq ,stack (cons (cons (quote ,a) ,a) ,stack))
		  (setf ,a ,v)))

(setq stack 's)
(setq s nil)
(macroexpand '(setfr (car x) (car y)))
(setq x 0)
(setfr x 5)
(defun unset (mark)
       (let ((s (symeval stack)))
	    (do ((l s (cdr l)))
		((eq (car l) mark) (set s (cdr (symeval s))))
		(setf (caar s) (cdar s))))) ; won't work, need unquoted version

(defmacro setf-save (a v s)
	  `(progn (push (cons (quote ,a) ,a) ,s) (setf ,a ,v)))
Features for a new Lisp

1. Numbers as selector functions.

2. (def (foo x y) body) instead of (defun foo (x y) body).  The idea
is that the form should be more like an equation.  To emphasize
this we might even write  (defequal (foo x y) body).

3. We need to separate objects from Cartesian products.

4. x/setf = set/setq

5. The backtracker analog to do.

6. Flexibility in prescribing whether an entity is to be restored
on return from recursion by remembering it on the stack or by
reverting an update.  It would be good if all reasonable methods
were flexibly available.